home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- CPixelWorld.h
-
- Interface for the PixelWorld Class
-
- The CPixelWorld class is a subclass of CBitMap designed to maintain a
- color offscreen drawing environment using the standard conventions of
- Color QuickDraw. An offscreen color graphics device (GDevice) and an
- offscreen color graphics port (CGrafPort) are used to maintain this
- offscreen world. This implementation supports 1,2,4 and 8 bit pixel
- depths. Pixel depths of 16 and 32 bits are currently not supported.
-
- This implementation does not depend upon any 32-Bit QuickDraw features.
- Future versions of the CPixelWorld class will provide support for pixel
- depths of 16 and 32 bits, and for GWorlds under 32-Bit QuickDraw.
-
- SUPERCLASS = CBitMap
-
- This implementation is based in part on material copyrighted by
- Symantec Corporation and Apple Computer, Inc.
-
- Copyright © 1992 Vincent R. Vann, Jr. All rights reserved.
-
- Version 1.1 Changes:
- [
- - CopyFrom and CopyTo methods were modified so that the foreground
- and background colors are set to black and white before calling
- CopyBits. This ensures that the PixelWorld image is copied with
- the proper colors. The foreground and background colors of the
- current CGrafPort are preserved by these methods.
- ]
-
- Version 1.2 Changes:
- [
- - added new instance variables saveFgColor and saveBgColor.
- - implemented new methods SaveColors, RestoreColors,
- CopyFromColors, and CopyToColors.
- - changed CopyFrom and CopyTo methods to use these color routines.
- - see comments for CopyFromColors and CopyToColors for information
- about how to colorize your image.
- ]
-
- ******************************************************************************/
-
- #define _H_CPixelWorld
-
- #include "CBitMap.h" /* Interface for its superclass */
- #include "LongCoordinates.h"
-
- class CPixelWorld : public CBitMap { /* Class Declaration */
-
- public:
- /** Instance Variables **/
-
- Boolean worldIsOK; /* TRUE if initialized successfully */
- Boolean worldHasColor; /* TRUE if have Color QuickDraw */
- Boolean worldHas32BitQD; /* TRUE if have 32-Bit QuickDraw */
- Boolean worldOwnsPixels; /* TRUE if world owns pixel image */
- Boolean worldPixelsLocked; /* TRUE if pixel image is locked */
-
- short worldDepth; /* Pixel depth */
- LongRect worldBounds; /* Bounds rectangle */
- CTabHandle worldColors; /* Color table handle */
- Handle worldPixels; /* Pixel image handle */
- GDHandle worldDevice; /* Offscreen GDevice handle */
- CGrafPtr worldPort; /* Offscreen CGrafPort pointer */
-
- GDHandle saveDevice; /* Saved graphics device */
- RGBColor saveFgColor; /* Saved foreground color */
- RGBColor saveBgColor; /* Saved background color */
-
- /** Instance Methods **/
-
- /** Contruction **/
- void IPixelWorld( short aPixelDepth, Rect *aBoundsRect,
- CTabHandle aColorTable, Handle aPixelImage,
- short aRowBytes);
- void IPixelWorldBW( short aPixelDepth, Rect *aBoundsRect,
- Handle aPixelImage, short aRowBytes);
- void IPixelWorldColor( short aPixelDepth, Rect *aBoundsRect,
- CTabHandle aColorTable, Handle aPixelImage,
- short aRowBytes);
-
- /** Destruction **/
- virtual void Dispose(void);
-
- /** Checking **/
- virtual Boolean WorldIsOK( void);
-
- /** Accessing Parameters **/
- virtual short GetPixelDepth( void);
- virtual void GetBounds( LongRect *theBounds);
- virtual short GetRowBytes( void);
-
- /** Accessing Pixels **/
- virtual Boolean PixelIsBlack( LongPt *pixelPos);
- virtual Boolean GetPixelColor( LongPt *pixelPos, RGBColor *color);
- virtual Handle GetHandleToPixels( void);
- virtual Ptr GetPointerToPixels( void);
-
- /** Setting Coordinates **/
- virtual void SetBoundsOrigin( short hOrigin, short vOrigin);
-
- /** Drawing **/
- virtual void BeginDrawing( void);
- virtual void EndDrawing( void);
-
- /** Activating **/
- virtual void ActivateWorld( void);
- virtual void DeactivateWorld( void);
- virtual Boolean LockWorld( Boolean setLock);
-
- /** Colors **/
- virtual void SaveColors( void);
- virtual void RestoreColors( void);
- virtual void CopyFromColors( void);
- virtual void CopyToColors( void);
-
- /** Copying **/
- virtual void CopyFrom( LongRect *fromRect, LongRect *toRect, RgnHandle maskRgn);
- virtual void CopyTo( LongRect *fromRect, LongRect *toRect, RgnHandle maskRgn);
- };
-
-
-